package org.lq.his.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.lq.his.pojo.SeeDoctorRegister;
import org.lq.his.service.SeeDoctorRegisterService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/seeDoctorRegister")
public class SeeDoctorRegisterController {
	
	@Resource
	private SeeDoctorRegisterService seeDoctorRegisterService;
	
	public void setSeeDoctorRegisterService(SeeDoctorRegisterService seeDoctorRegisterService) {
		this.seeDoctorRegisterService = seeDoctorRegisterService;
	}

	@RequestMapping("/seeDoctorRegister")
	public String SeeDoctorRegister()throws Exception{
		
		return "seeDoctorRegister/seeDoctorRegister";
	}

	@RequestMapping("/seeDoctorRegisterForm")
	public String seeDoctorRegisterForm()throws Exception{
		return "seeDoctorRegister/seeDoctorRegisterForm";
	}
	
	@RequestMapping("/add")
	@ResponseBody
	public Map<String, Object> addseeDoctorRegister(SeeDoctorRegister seeDoctorRegister)throws Exception {
		
		String result = seeDoctorRegisterService.add(seeDoctorRegister);
		Map<String, Object> map = new HashMap<>();
		map.put("result", result);
		
		return map;
		
	}
	@RequestMapping("/selectList")
	@ResponseBody
	public Map<String, Object> selectList(@RequestParam(defaultValue="1")Integer  page,@RequestParam(defaultValue="5")Integer  rows,@RequestParam(defaultValue="id")String sort,@RequestParam(defaultValue="asc")String order,SeeDoctorRegister condition)throws Exception{
		Map<String, Object> map = new HashMap<>();
		
		int start = (page-1)*rows;
		List<SeeDoctorRegister> list = seeDoctorRegisterService.getListByCondition(start, rows, condition,sort,order);
		int total = seeDoctorRegisterService.getCountByCondition(condition);
		map.put("rows", list);
		map.put("total", total);
		return map;
	}
}
